<!DOCTYPE html>
<html lang="zh">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>父子传参</title>
    <script src="https://cdn.staticfile.org/react/16.4.0/umd/react.development.js"></script>
    <script src="https://cdn.staticfile.org/react-dom/16.4.0/umd/react-dom.development.js"></script>
    <script src="https://cdn.staticfile.org/babel-standalone/6.26.0/babel.min.js"></script>
</head>

<body>
    <div id="root"></div>
    <div id="root2"></div>
    <div id="root3"></div>
    <div id="root4"></div>
    <script type="text/babel">
        // 组建有两种做法：函数方式和类方式
        // 函数方式
        function HelloName(props) {
            return <h2>hello, {props.name}</h2>
        }

        ReactDOM.render(HelloName({ name: "后端码匠" }), root)

        // 语法糖 运行时 babel工具会自动编译  HelloName({ name: "后端码匠"})
        ReactDOM.render(<HelloName name="后端码匠" />, root2)

        // 复用
        let more = (
            <div>
                <HelloName name="你好" />
                <HelloName name="贝贝" />
                <HelloName name="晶晶" />
                <HelloName name="欢欢" />
                <HelloName name="映映" />
                <HelloName name="嘻嘻" />
            </div>
        )
        ReactDOM.render(more, root3)

    </script>
</body>

</html>